/*
 * Copyright 2012 Marsrutai.lt
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package lt.marsrutai.mobile.android.model.enums;

public enum WeekdayType {
    MONDAY("monday"), TUESDAY("tuesday"), WEDNESDAY("wednesday"), THURSDAY("thursday"), FRIDAY("friday"), SATURDAY("saturday"), SUNDAY("sunday");

    private String value;

    WeekdayType(String value) {
        this.value = value;
    }

    public static WeekdayType parseEnum(String string) {
        for (WeekdayType weekdayType: values()) {
            if (weekdayType.toString().equals(string)) {
                return weekdayType;
            }
        }

        throw new IllegalArgumentException("Cannot parse enum WeekdayType from " + string);
    }

    public static WeekdayType parseEnumSunSat(int weekday) {
        switch (weekday) {
        case 0:
            return WeekdayType.SUNDAY;
        case 1:
            return WeekdayType.MONDAY;
        case 2:
            return WeekdayType.TUESDAY;
        case 3:
            return WeekdayType.WEDNESDAY;
        case 4:
            return WeekdayType.THURSDAY;
        case 5:
            return WeekdayType.FRIDAY;
        case 6:
            return WeekdayType.SATURDAY;
        default:
            throw new IllegalArgumentException("Cannot parse enum WeekdayType (Sun to Sat) from " + weekday);
        }
    }

    public static WeekdayType parseEnumMonSun(int weekday) {
        switch (weekday) {
        case 0:
            return WeekdayType.MONDAY;
        case 1:
            return WeekdayType.TUESDAY;
        case 2:
            return WeekdayType.WEDNESDAY;
        case 3:
            return WeekdayType.THURSDAY;
        case 4:
            return WeekdayType.FRIDAY;
        case 5:
            return WeekdayType.SATURDAY;
        case 6:
            return WeekdayType.SUNDAY;
        default:
            throw new IllegalArgumentException("Cannot parse enum WeekdayType (Mon to Sun) from " + weekday);
        }
    }

    @Override
    public String toString() {
        return value;
    }
}
